package com.csust.travel.controller;


import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.SaTokenInfo;
import com.csust.travel.model.DTO.UserLoginDto;
import com.csust.travel.model.R;
import com.csust.travel.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/public")
@SaCheckLogin
public class PublicController {
    @Autowired
    private UserService userService;



    @PostMapping("/user/login")
    public R<SaTokenInfo> login(@RequestBody UserLoginDto request) {
        SaTokenInfo loginToken = userService.login(request);
        return R.ok(loginToken);
    }

    @PostMapping("/user/login/pwd")
    public R<SaTokenInfo> loginPwd(@RequestBody UserLoginDto request){
        SaTokenInfo loginToken = userService.loginPwd(request);
        return R.ok(loginToken);
    }
}
